var fs=require('fs');
var path=require('path');

module.exports.tsc=function(inputFile,callback){
	if(path.extname(inputFile)!=='.ts'){
		throw new Error('file not type .ts');
	}
	var outputFile=inputFile.replace(/.ts/g,'.js');
	var inputStr=fs.readFileSync(inputFile,'utf-8');
	fs.exists(inputFile,(exists)=>{
		if(exists){
			fs.writeFile(outputFile,inputStr,'utf-8',(err)=>{
				if (err) throw err;
				callback(outputFile);
			});
		}else{
			throw new Error('file not exists!');
		}
	})
}